/*
This file must be encoded with ASCII , because of WSHShell NOT support UTF-8
*/

// must input 17 bit string of RID from left to right
function calcChecksum(rid){
	var workArr = rid.split('').reverse();
	function W(i){
		return Math.pow(2,i-1) % 11;
	}
	function S(){
		var sum = 0;
		for (var j=0;j<17;j++){
			sum += workArr[j]*W(j+2);
		}
		
		return sum;
	}
	
	return (12-(S() % 11)) % 11;
}

//test
var WSHShell = WScript.CreateObject("WScript.Shell");
WSHShell.Popup(calcChecksum('63280119790817003'));